#include <stdint.h>

#ifndef __ROM_PLAYER_H
#define __ROM_PLAYER_H 1

/* TODO: actually type out the comments for number comment indicators ([1] etc)*/

/* Object ID bitmasks when objectType = TYPE_PLAYER */
# define PLAYER_MALE    0x00
# define PLAYER_FEMALE  0x01
# define PLAYER_HUMAN   0x00
# define PLAYER_ELF	    0x02

/* These object types are all still in early observations I'm not sure of any of these
 * By playing with the value I could make a guard show up as a player game master, not sure how that happens yet
 */
# define TYPE_PLAYER	1
# define TYPE_MONSTER	2
# define TYPE_NPC 		4

//player structure
struct RomObject
{
/* 000 */   uint8_t             unknown0[20];
/* 014 */   uint32_t            objectId;	    // Object ID [1]
/* 018 */   uint32_t            objectType;     // Type of the object [2]
/* 01C */   uint8_t             unknown1[12];
/* 028 */   float               coordX;         // current y coord on the world [3]
/* 02C */   float               coordZ;         // current z coord on the world
/* 030 */   float               coordY;         // current x coord on the world
/* 034 */   float               vectorX;        // X axis vector [4]
/* 038 */   float               vectorZ;        // Z axis vector
/* 03C */   float               vectorY;        // Y axis vector
/* 040 */   float               speed;          // Current movement speed
/* 044 */   uint8_t             unknown2[16];
/* 054 */   float               modelTiltR;     // how far the model is tilted backwards [5]
/* 058 */   uint8_t             unknown3[8];
/* 060 */   float               modelTiltRW;    // how far the model is tilted backwards [4]
/* 064 */   uint8_t             unknown4[12];
/* 070 */   float               modelScale1;    // Model Scale [5]
/* 074 */   float               modelScale2;    // Model scale
/* 078 */   float               transparency;   // transparancy [6]
/* 07C */   uint8_t             unkwown5[424];
/* 224 */   uint32_t            flags;          // may be larger [7]
/* 228 */   uint8_t             unknown6[48];
/* 258 */   uint32_t            castId;         // ID of the current casting spell [6]
/* 25C */   float               castMax;        // Total Required cast time in seconds
/* 260 */   float               castNow;        // Cast time elapsed in seconds
/* 264 */   uint8_t             unknown7[4];
/* 268 */   struct RomBuff     *buffStart;      // Pointer to the beginning of the buff struct (More info below struct in comments)
/* 26C */   void               *buffEnd;        // "End pointer" of the buff struct (more info below struct in comments)
/* 270 */   void               *buffMax;        // "max pointer" of the buff struct (more info below struct in comments)
/* 274 */   struct RomObject   *target;         // Pointer to target structure (read down for more info)
/* 278 */   uint8_t             unknown8[24];
/* 290 */   char               *name;           // Object name
/* 294 */   char               *title;          // Object title
/* 298 */   char               *guild;          // Guildname
/* 29C */   uint8_t             unknown9[44];
/* 2C8 */   uint32_t            health;         // Current health points
/* 2CC */   uint32_t            healthLag;      // Previous health points, right before you took damage
/* 2D0 */   uint32_t            healthMax;      // Maximum health points
/* 2D4 */   uint32_t            power1;         // main class current power
/* 2D8 */   uint32_t            power1Max;      // main class max power
/* 2DC */   uint32_t            power2;         // secondary class current power
/* 2E0 */   uint32_t            power2Max;      // secondary class max power
/* 2E4 */   uint8_t             unknown10[24];
/* 2FC */   uint32_t            class1;         // main class ID
/* 300 */   uint32_t            level1;         // main class level
/* 304 */   uint32_t            class2;         // secondary class ID
/* 308 */   uint32_t            level2;         // secondary class level
/* 30C */   uint8_t             unknown11[50];
/* 33E */   uint8_t             stealth;        // 0x01 = stealthed, 0x00 = visible

//Structure might go even further, this is the last part I could identify
} __attribute__((packed));


/*****************
 *   MOAR INFO   *
 *****************
 *
 *
 * FLAGS
 *******
 * 0x04 == melee attack on
 * 0x20 == sitting
 *
 *
 * X AXIS
 ********
 * -0.999 to -0.5 to 0 is south to west to north 
 *  0.999 to  0.5 to 0 is south to east to north 
 *
 *
 * Y AXIS
 ********
 * -0.95 to 0 to 0.95 is looking down to forward to up
 *
 *
 * MOVEMENT
 **********
 * base_pointer + 0xA3C is a movement flag integer (32 bits I think)
 * Writing to it allows you to move your character without having RoM focused
 * 0x01 = forward
 * 0x02 = backward
 * 0x04 = strafe right
 * 0x08 = strafe left
 * 0x10 = turn right
 * 0x20 = turn left
 * 0x40--> not entirely sure about all its meanings but autorun and pressing both mouse buttons at once uses this bit
 *
 *
 * TARGET STRUCTURE
 ******************
 * the target id is actually a target pointer, it looks exactly like the player struct for both mobs and player targets
 * It also looks like the player struct is just part of a larger array with ALL mobs and players nearby but I cant figure out how to get to the start of that yet :)
 *
 *
 * BUFF POINTERS
 ***************
 * buff_start --> This is the pointer where the buff structure array starts (struct ROM_BUFF buffarr[];)
 * buff_end   --> This is the first unused pointer in the buff struct, basically your struct has to be below this address or it is invalid
 *                example: This will be equal to buff_start if 0 buffs are active
 *                example: This will be equal to buff_start + sizeof(struct ROM_BUFF) if 1 buff is active
 * buff_max   --> This seems to be the last address that is allocated, but I'm not sure about this (works similar to buff_end)
 *
 */

#endif
